<?php
namespace App\HttpController\Admin;

use App\HttpController\Model\Base\NodeModel;
use App\Repositories\Contracts\BaseOperateRepository;
use App\Repositories\Eloquent\Admin\ExampleModel;
use EasySwoole\Template\Render;

class Example extends Sys implements BaseOperateRepository {

    private  $_model;

    public function index()
    {

    }

    public function getList()
    {

    }

    public function add()
    {

    }

    public function add_ajax()
    {

    }

    public function edit()
    {
        $this->_model = new ExampleModel();
        $id = 100;
        $item = [];
        if ($id > 0) {
            $tmp['id'] = $id;
            $item = $this->_model->getItemByid($id);
        }
        $this->show('admin/example/edit',['item'=>$item]);

    }

    public function edit_ajax()
    {
        $this->_model = new ExampleModel();
        $id = $this->_params['id'];
        if ($id > 0) {
            unset($this->_params['id']);
            $item = $this->_params;
            $reslut = $this->_model->updateItemById($id, $item);
            if ($reslut) {
                $this->ajaxSuccess();
            }
            $this->ajaxError(0,"参数错误");
        }
    }

    public function status()
    {

    }

    public function del()
    {


    }

    public function sort()
    {
        // TODO: Implement px() method.
    }






    function reload(){
        Render::getInstance()->restartWorker();
        $this->response()->write(1);
    }

    protected function gc()
    {
        parent::gc(); // TODO: Change the autogenerated stub
        $this->_model = null;
    }


}
